package messengercommon.person;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author Samus
 */
@Entity
@NamedQueries({
    @NamedQuery(name = "buscarPersonPorNombre",
    query = "SELECT p FROM Person p WHERE p.username = :username")})
public class Person extends Contact implements Serializable {

    private String password;
    private List<Contact> contacts;

    public Person() {
        contacts = new ArrayList<Contact>();
    }

    @OneToMany
    @LazyCollection(LazyCollectionOption.FALSE)
    public List<Contact> getContacts() {
        return contacts;
    }

    public void setContacts(List<Contact> contacts) {
        this.contacts = contacts;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return this.getStatus() + " - " + this.getNick() + " - " + this.getUsername();
    }
}
